package cn.itcast.zhoumingxin.controller;

import java.io.IOException;
import java.io.PipedWriter;
import java.io.PrintWriter;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import cn.itcast.zhoumingxin.annotation.EnjoryAutowired;
import cn.itcast.zhoumingxin.annotation.EnjoryController;
import cn.itcast.zhoumingxin.annotation.EnjoryRequestMapping;
import cn.itcast.zhoumingxin.annotation.EnjoryRequestParam;
import cn.itcast.zhoumingxin.service.JamesService;

@EnjoryController
@EnjoryRequestMapping("/james")
public class JamesController {
	
	@EnjoryAutowired("JamesServiceImpl")
	private JamesService jamesService;
	
	@EnjoryRequestMapping("/query")
	public void query(HttpServletRequest request,HttpServletResponse response,
						@EnjoryRequestParam("name") String name,
						@EnjoryRequestParam("age") String age) {
		try {
			PrintWriter ps = response.getWriter();
			String result = jamesService.query(name, age);
			ps.write(result);
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}
